package builder.AssetFormBuilderPackage;


import handler.assetFormHandlers.AFComboBoxAssetSelectorListener;

import java.awt.GridBagConstraints;
import javax.swing.JComboBox;

import customGUI.selectors.AssetSelector;
import customGUI.selectors.ComboBoxAssetSelector;


import builder.FormBuilder;
import builder.FormBuilderDecorator;

import form.AssetForm.AssetForm;

public class RetrieveDecorator extends FormBuilderDecorator {

	GridBagConstraints c = new GridBagConstraints();
	
	public RetrieveDecorator(FormBuilder decoratee){
		super(decoratee);
	}
	
	
	public void setFormSettings() {
		// TODO Auto-generated method stub
		super.setFormSettings();
	}

	@Override
	public void buildComponents() {
		// TODO Auto-generated method stub
	
		super.buildComponents();
		
		AssetForm assetForm = (AssetForm) decoratee.getForm();
		
		c.gridx = 0;
		c.gridy = 0;
		
		AssetSelector selector = new ComboBoxAssetSelector("Select Asset: <name>-<id>");
		
		((JComboBox)selector.getSelector()).addActionListener(new AFComboBoxAssetSelectorListener(assetForm, (ComboBoxAssetSelector)selector));
		assetForm.setSelector(selector);
		assetForm.add(selector, c);
		
		assetForm.populate(selector.getSelectedID());
		
	} 
}
